package com.kingyun.gpsinspection.purificationservice.services.activitiservice.ext.behavior;

import org.activiti.bpmn.model.UserTask;
import org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
import org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.task.TaskDefinition;

/**
 * 自定义行为工厂类
 * @author zjh
 * @since 20170601
 */
public class CustomerActivityBehaviorFactory extends DefaultActivityBehaviorFactory {


    /**&
     * 重写用户任务行为工厂类
     * @param userTask
     * @param taskDefinition
     * @return
     */
    @Override
    public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition) {
        return new CustomerUserTaskActivityBehavior(userTask.getId(),taskDefinition);
    }

    /**
     * 重写用户并行多实例
     * @param activity
     * @param innerActivityBehavior
     * @return
     */
    @Override
    public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(ActivityImpl activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
        return new CustomerParallelMultiInstanceBehavior(activity,innerActivityBehavior);
    }


    /**
     * 重写用户顺序多实例
     * @param activity
     * @param innerActivityBehavior
     * @return
     */
    @Override
    public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(ActivityImpl activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
        return new CustomerSequeMultiInstanceActivityBehavior(activity,innerActivityBehavior);
    }
}
